package com.laoye.big_event.Mapper;

import com.laoye.big_event.Pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserMapper{
//    查询用户
    @Select("select * from user where username=#{username}")
    User SelectByUsername(String username);
//     注册用户
    @Insert("insert into user(username,password,create_time,update_time)"+
    "values (#{username},#{password},now(),now())")
    void RegisterUser(String username, String password);
//      更新用户基本信息
    @Update("update user set nickname=#{nickname},email=#{email},update_time=now() where id=#{id}")
    void update(User user);
//      更新头像
    @Update("update user set user_pic=#{avatarUrl},update_time=now() where id=#{id}")
    void updateAvatar(String avatarUrl,int id);
//       更改密码
    @Update("update user set password=#{newPwd},update_time=now() where id=#{id}")
    void updatePwd(String newPwd, int id);
}
